home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Finder Dungeon / source code / MoreFiles 1.4.6 / Pascal Interfaces / FullPath.p < prev    next >
Encoding:
Text File  |  1997-06-28  |  4.1 KB  |  100 lines  |  [TEXT/MPS ]

  1. UNIT FullPath;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    Routines for dealing with full pathnames... if you really must.            }
  6. {                                                                            }
  7. {    by Jim Luther, Apple Developer Technical Support Emeritus                }
  8. {                                                                            }
  9. {    File:        FullPath.p                                                    }
  10. {                                                                            }
  11. {    Copyright © 1995-1996 Apple Computer, Inc.                                }
  12. {    All rights reserved.                                                    }
  13. {                                                                            }
  14. {    You may incorporate this sample code into your applications without        }
  15. {    restriction, though the sample code has been provided "AS IS" and the    }
  16. {    responsibility for its operation is 100% yours.  However, what you are    }
  17. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  18. {    after having made changes. If you're going to re-distribute the source,    }
  19. {    we require that you make it clear in the source that the code was        }
  20. {    descended from Apple Sample Code, but that you've made changes.            }
  21.  
  22.  
  23. {    IMPORTANT NOTE:                                                            }
  24. {                                                                            }
  25. {    The use of full pathnames is strongly discouraged. Full pathnames are    }
  26. {    particularly unreliable as a means of identifying files, directories    }
  27. {    or volumes within your application, for two primary reasons:            }
  28. {                                                                            }
  29. {    •     The user can change the name of any element in the path at            }
  30. {        virtually any time.                                                    }
  31. {    •    Volume names on the Macintosh are *not* unique. Multiple            }
  32. {        mounted volumes can have the same name. For this reason, the use of    }
  33. {        a full pathname to identify a specific volume may not produce the    }
  34. {        results you expect. If more than one volume has the same name and    }
  35. {        a full pathname is used, the File Manager currently uses the first    }
  36. {        mounted volume it finds with a matching name in the volume queue.    }
  37. {                                                                            }
  38. {    In general, you should use a file’s name, parent directory ID, and        }
  39. {    volume reference number to identify a file you want to open, delete,    }
  40. {    or otherwise manipulate.                                                }
  41. {                                                                            }
  42. {    If you need to remember the location of a particular file across        }
  43. {    subsequent system boots, use the Alias Manager to create an alias        }
  44. {    record describing the file. If the Alias Manager is not available, you    }
  45. {    can save the file’s name, its parent directory ID, and the name of the    }
  46. {    volume on which it’s located. Although none of these methods is            }
  47. {    foolproof, they are much more reliable than using full pathnames to        }
  48. {    identify files.                                                            }
  49. {                                                                            }
  50. {    Nonetheless, it is sometimes useful to display a file’s full pathname    }
  51. {    to the user. For example, a backup utility might display a list of full    }
  52. {    pathnames of files as it copies them onto the backup medium. Or, a        }
  53. {    utility might want to display a dialog box showing the full pathname of    }
  54. {    a file when it needs the user’s confirmation to delete the file. No        }
  55. {    matter how unreliable full pathnames may be from a file-specification    }
  56. {    viewpoint, users understand them more readily than volume reference        }
  57. {    numbers or directory IDs.                                                }
  58. {                                                                            }
  59. {    The following technique for constructing the full pathname of a file is    }
  60. {    intended for display purposes only. Applications that depend on any        }
  61. {    particular structure of a full pathname are likely to fail on alternate    }
  62. {    foreign file systems or under future system software versions.            }
  63.  
  64.  
  65. INTERFACE
  66.  
  67.     USES
  68.         Types, Files;
  69.  
  70. {***************************************************************************}
  71.  
  72.  
  73.     FUNCTION GetFullPath (vRefNum: INTEGER;
  74.                                     dirID: LONGINT;
  75.                                     name: StringPtr;
  76.                                     VAR fullPathLength: INTEGER;
  77.                                     VAR fullPath: Handle): OSErr;
  78.  
  79.     FUNCTION FSpGetFullPath ({CONST}
  80.                                     VAR spec: FSSpec;
  81.                                     VAR fullPathLength: INTEGER;
  82.                                     VAR fullPath: Handle): OSErr;
  83.  
  84.     FUNCTION FSpLocationFromFullPath (fullPathLength: INTEGER;
  85.                                     fullPath: Ptr;
  86.                                     VAR spec: FSSpec): OSErr;
  87.  
  88.     FUNCTION LocationFromFullPath (fullPathLength: INTEGER;
  89.                                     fullPath: Ptr;
  90.                                     VAR vRefNum: INTEGER;
  91.                                     VAR parID: LONGINT;
  92.                                     VAR name: Str31): OSErr;
  93.  
  94.  
  95. {***************************************************************************}
  96.  
  97.  
  98. IMPLEMENTATION
  99.  
  100. END.